package com.cgsd.heyu.ui.home.fragment;

import android.widget.ProgressBar;

import com.cgsd.heyu.R;
import com.cgsd.heyu.api.AppConfig;
import com.cgsd.heyu.ui.BaseFragment;
import com.cgsd.heyu.widgets.CustomWebView;
import com.cgsd.heyu.widgets.ErrorCustomView;
import com.tencent.smtt.sdk.WebView;
import com.tencent.smtt.sdk.WebViewClient;

/**
 * @author xiaoxing
 * Description 首页品牌
 * CreateData: 2020/11/3
 */
@Deprecated
public class BrandFragment extends BaseFragment {
    private CustomWebView mWebView;
    private ProgressBar mProgressBar;
    private ErrorCustomView mErrorView;

    @Override
    protected int getLayoutResId() {
        return R.layout.fragment_diary;
    }

    @Override
    protected void initView() {
        mWebView = findViewById(R.id.mWebView);
        mProgressBar = findViewById(R.id.mProgressBar);
        mErrorView = findViewById(R.id.mErrorView);

        mWebView.setWebViewClient(new WebViewClient() {
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                view.loadUrl(url);
                //true为在webView中打开
                return true;
            }
        });

//        mWebView.setWebChromeClient(new WebChromeClient(){
//            @Override
//            public void onProgressChanged(WebView webView, int newProgress) {
//                super.onProgressChanged(webView, newProgress);
//                if(newProgress == 100){
//                    //加载完网页进度条消失
//                    mProgressBar.setVisibility(View.INVISIBLE);
//                }
//                else{
//                    mProgressBar.setVisibility(View.VISIBLE);//开始加载网页时显示进度条
//                    mProgressBar.setProgress(newProgress);//设置进度值
//                }
//            }
//        });

    }

    @Override
    protected void initData() {
        mWebView.loadUrl(AppConfig.BRAND_H5);

        mErrorView.showEmpty(R.mipmap.default_developing,"功能正在开发中");
    }
}
